package ru.amse.tsyganov.jumleditor.main;

import ru.amse.tsyganov.jumleditor.editor.Editor;
import ru.amse.tsyganov.jumleditor.model.ActivityGraph;
import ru.amse.tsyganov.jumleditor.model.Partition;
import ru.amse.tsyganov.jumleditor.model.State;
import ru.amse.tsyganov.jumleditor.view.ActivityGraphView;
import ru.amse.tsyganov.jumleditor.view.PartitionView;
import ru.amse.tsyganov.jumleditor.view.StateView;
import ru.amse.tsyganov.jumleditor.view.ViewElementFactory;

public class Main {

	public static void main(String[] args) {
		ActivityGraphView<ActivityGraph> graph = createStatesModel();
		new Editor(graph);
	}

	/**
	 * @return
	 */
	private static ActivityGraphView<ActivityGraph> createStatesModel() {
		
		ActivityGraphView<ActivityGraph> viewGraph = 
			ViewElementFactory.factory.createActivityGraphView();
		
		PartitionView<Partition> pv = ViewElementFactory.factory.createPartitionView();
		
		viewGraph.getModel().getPartitions().add(pv.getModel());
		
		StateView<? extends State> v1 = ViewElementFactory.factory.createActionStateView();
		StateView<? extends State> v2 = ViewElementFactory.factory.createActionStateView();
		StateView<? extends State> v3 = ViewElementFactory.factory.createActionStateView();
		
		//TransitionView<Transition> tv1 = 
			ViewElementFactory.factory.createTransitionView(
					v1.getModel().getStateVertex(), 
					v2.getModel().getStateVertex());
		
		//TransitionView<Transition> tv2 = 
			ViewElementFactory.factory.createTransitionView(
					v2.getModel().getStateVertex(), 
					v3.getModel().getStateVertex());
				
		viewGraph.getModel().getPartitions().get(0).getContents().add(v1.getModel());
		viewGraph.getModel().getPartitions().get(0).getContents().add(v2.getModel());
		viewGraph.getModel().getPartitions().get(0).getContents().add(v3.getModel());
		
		v1.setX(10);
		v1.setY(100);
		
		v2.setX(200);
		v2.setY(10);
		
		v3.setX(310);
		v3.setY(200);
		
		return viewGraph;
	}
}
